<template>
  <div :class="['title', fontColor ,backgroundColor]">
    <span><van-icon v-if="LeftSlot" name="arrow-left" @click="$router.back()"/></span>
    <h1>{{ title }}</h1>
    <em>
      <slot v-if="rightSlot" name="search"></slot>
    </em>
  </div>
</template>

<script>
export default {
  name: "Title",
  props: {
    title: {
      type: String,
    },
    fontColor: {
      type: String,
    },
    backgroundColor: {
      type: String,
    },
    rightSlot: {
      type: Boolean,
      default: false
    },
    LeftSlot:{
      type: Boolean,
      default: true
    }
  },
}
</script>

<style lang="scss" scoped>
.title {
  width: 100%;
  height: 50px;
  position: absolute;
  top: 0;
  left: 0;
  //line-height: 50px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;

  span {
    flex-basis: 10%;
    line-height: 55px;
  }

  h1 {
    flex-basis: 60%;
    font-size: 16px;
  }

  em {
    flex-basis: 10%;
  }
}

.blue {
  background-color: #3967FF;
}

.white {
  background-color: white;
  border-bottom: 1px solid #ddd;
  color: #3967FF;
  position: fixed;
}

.fontBlack {
  color: black;
}
</style>